package lab02.test21;


public class Test {
    public static void main(String[] args) {
        //统计一个字符串中给定字符出现的频率
        String result = "12e323567658";//定义字符串
        char ch = '2';//求该数出现的次数
        int count = 0;//记录ch出现次数

        for (int i = 0; i < result.length(); i++) {
            char tmp = result.charAt(i);//将字符单独弄出来
            if (tmp == ch) {
                count++;
            }
        }
        System.out.println(ch + "出现的次数为：" + count);
    }
}
